rm(list = ls())

## packages 

library(tidyverse)
library(fixest)

## Load data 

dat <- readRDS('data/civey_clean.rds') %>%
  mutate(naturbad_post = naturbad_in_zip * summer_bin) %>% ## placebo treatment  
  mutate(naturbad_in_zip_char = recode(naturbad_in_zip, 
                                       `1` = 'Natural pool in locality', ## character version for table header 
                                       `0` = 'No natural pool')) 

## Table A18 

feols(vote_afd ~ treated_post | user_id + date, 
            data = dat %>% filter(foreign_non_eu_share_bin == 'High'),
            split = ~ naturbad_in_zip_char, 
            cluster = ~ user_id) %>%
  etable()

## Table A19

feols(vote_afd ~ treated_post + naturbad_post | user_id + date, 
            data = dat,
            fsplit = ~ foreign_non_eu_share_bin, 
            cluster = ~ user_id) %>%
  etable()


## Table A20

feols(vote_afd ~ naturbad_post | user_id + date, 
            data = dat,
            fsplit = ~ foreign_non_eu_share_bin, 
            cluster = ~ user_id) %>%
  etable()


